package org.wheel.plugins.toolkit.sql.page.impl;

import org.wheel.plugins.toolkit.sql.enums.Dialect;
import org.wheel.plugins.toolkit.sql.page.BuiltinPaginationStrategy;
import org.wheel.plugins.toolkit.sql.page.PaginationStrategy;
import org.wheel.plugins.toolkit.sql.page.PaginationStrategyFactory;

/**
 * 分页策略工厂
 */
public class PaginationStrategyFactoryImpl implements PaginationStrategyFactory {
    @Override
    public PaginationStrategy createPaginationStrategy(Dialect dialectName) {

        return switch (dialectName) {
            case POSTGRESQL -> BuiltinPaginationStrategy.POSTGRESQL;
            case H2, MYSQL, SQLITE3, PHOENIX -> BuiltinPaginationStrategy.MYSQL;
            case ANSI, ORACLE, SQLSERVER2012 -> BuiltinPaginationStrategy.ORACLE;
            // 添加其他数据库的工厂
            default -> throw new IllegalArgumentException("Unsupported database type: " + dialectName);
        };
    }

}
